package cn.tedu.ivoscm.distribute.controller;

import cn.tedu.ivoscm.application.pojo.vo.ApplicationVO;
import cn.tedu.ivoscm.base.response.JsonResult;
import cn.tedu.ivoscm.distribute.pojo.dto.DistributeParam;
import cn.tedu.ivoscm.distribute.pojo.dto.DistributeQuery;
import cn.tedu.ivoscm.distribute.service.DistributeService;
import io.swagger.annotations.Api;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Slf4j
@RestController
@RequestMapping("/v1/distribute")
@Api(tags = "08.分配管理")
public class DistributeController {
    @Autowired
    DistributeService distributeService;

    @GetMapping("select")
    public JsonResult select(DistributeQuery dq) {
        log.debug("开始处理【查询工单】的请求");
        List<ApplicationVO> list = distributeService.select(dq);
        return JsonResult.ok(list);
    }

    @PostMapping("allocation")
    public JsonResult allocation(DistributeParam dp) {
        log.debug("开始处理【分配用车】的请求");
        distributeService.allocation(dp);
        return JsonResult.ok();
    }

    @PostMapping("returnVehicle")
    public JsonResult returnVehicle(DistributeParam dp) {
        log.debug("开始处理【归还车辆】的请求");
        distributeService.returnVehicle(dp);
        return JsonResult.ok();
    }
}
